<?php

namespace Kunfeng\Dify\Event;

/**
 * 错误事件
 */
class ErrorEvent extends BaseEvent
{
    private $message;
    private $code;

    public function __construct(
        string $event,
        array $data = []
    ) {
        parent::__construct($event, $data);
        
        $this->message = $data['message'] ?? '';
        $this->code = $data['code'] ?? null;
    }

    /**
     * 从数组创建事件
     */
    public static function fromArray(array $data)
    {
        return new self($data['event'] ?? 'error', $data);
    }

    public function getMessage(): string
    {
        return $this->message;
    }

    public function getCode(): ?string
    {
        return $this->code;
    }
}
